import json

import execjs
import requests

cookies = {
    '_ga': 'GA1.2.608012681.1726029820',
    '_gat': '1',
    'sajssdk_2015_cross_new_user': '1',
    'auth_token': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MjYwNjI3ODc1LCJleHAiOjE3MjY4OTQxNjAsImV4cF92MiI6MTcyNjg5NDE2MCwiZGV2aWNlIjoiIiwidXNlcm5hbWUiOiJXZWNoYXRfYjQ1OTdkMTFlOWUxOTM1ZiIsImlzX3N0YWZmIjowLCJzZXNzaW9uX2lkIjoiODJhZjM0NDA2ZmY4MTFlZjg1NzM0YWU3ZWZiYTkxYjkifQ.ybcjc9xwQDeTwpfSRv2jlCc3fMBQwLupYcpvQf17pbQ',
    'csrftoken': 'd9858d879d14adc8f1179e2264c29e43',
    'sensorsdata2015jssdkcross': '%7B%22distinct_id%22%3A%22gvbpgt%22%2C%22first_id%22%3A%22191df64f0b1806-08eac191d1abc-4c657b58-1327104-191df64f0b2815%22%2C%22props%22%3A%7B%22%24latest_traffic_source_type%22%3A%22%E7%A4%BE%E4%BA%A4%E7%BD%91%E7%AB%99%E6%B5%81%E9%87%8F%22%2C%22%24latest_search_keyword%22%3A%22%E6%9C%AA%E5%8F%96%E5%88%B0%E5%80%BC%22%2C%22%24latest_referrer%22%3A%22https%3A%2F%2Fopen.weixin.qq.com%2F%22%7D%2C%22%24device_id%22%3A%22191df64f0b1806-08eac191d1abc-4c657b58-1327104-191df64f0b2815%22%7D',
    'tfstk': 'fGIt3sAlBWVMipMKJqaHm_fJDLwnMiBNJ1WSmIAil6CdF_e2lCjDDZCAMAYb_hjA9T1eniAijmLvOIRsshYDHIOhFRyViRkN8_XSjG4wmmKw0nNuZuqoQO-2crEvPlcwAKprlovXCAPnVuVuZuq3GMZN67b08oFnJKRBCdiscJKBnLtjGI1XOe9WEftfGnwKALpt1AtXhptBTKtXGstjN4D9iAOxDZac8FaujboxDMpQgQBTQcpl4dL9NOstMjeyBFd5CBFl4ZmkRt8A0xovkO_PgL1s1SdVv9s1P_NnSC_JHTbACliBjGW1PEs7gq6wjCKCfaHjc9K9ssIATfFpNGWC4HT3V8BCY1XNvtDbcpfkOOS6DuwyXhO6vpS0TcOARZsM7nl_MISddG_A4fsl2acmZQpm5JeKuq86LR_juxByMUQMpQ2n-qu2-pJpZJeKuq86LpduKk0quevF.',
}

headers = {
    'accept': 'application/json, text/plain, */*',
    'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
    # 'cookie': '_ga=GA1.2.608012681.1726029820; _gat=1; sajssdk_2015_cross_new_user=1; auth_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MjYwNjI3ODc1LCJleHAiOjE3MjY4OTQxNjAsImV4cF92MiI6MTcyNjg5NDE2MCwiZGV2aWNlIjoiIiwidXNlcm5hbWUiOiJXZWNoYXRfYjQ1OTdkMTFlOWUxOTM1ZiIsImlzX3N0YWZmIjowLCJzZXNzaW9uX2lkIjoiODJhZjM0NDA2ZmY4MTFlZjg1NzM0YWU3ZWZiYTkxYjkifQ.ybcjc9xwQDeTwpfSRv2jlCc3fMBQwLupYcpvQf17pbQ; csrftoken=d9858d879d14adc8f1179e2264c29e43; sensorsdata2015jssdkcross=%7B%22distinct_id%22%3A%22gvbpgt%22%2C%22first_id%22%3A%22191df64f0b1806-08eac191d1abc-4c657b58-1327104-191df64f0b2815%22%2C%22props%22%3A%7B%22%24latest_traffic_source_type%22%3A%22%E7%A4%BE%E4%BA%A4%E7%BD%91%E7%AB%99%E6%B5%81%E9%87%8F%22%2C%22%24latest_search_keyword%22%3A%22%E6%9C%AA%E5%8F%96%E5%88%B0%E5%80%BC%22%2C%22%24latest_referrer%22%3A%22https%3A%2F%2Fopen.weixin.qq.com%2F%22%7D%2C%22%24device_id%22%3A%22191df64f0b1806-08eac191d1abc-4c657b58-1327104-191df64f0b2815%22%7D; tfstk=fGIt3sAlBWVMipMKJqaHm_fJDLwnMiBNJ1WSmIAil6CdF_e2lCjDDZCAMAYb_hjA9T1eniAijmLvOIRsshYDHIOhFRyViRkN8_XSjG4wmmKw0nNuZuqoQO-2crEvPlcwAKprlovXCAPnVuVuZuq3GMZN67b08oFnJKRBCdiscJKBnLtjGI1XOe9WEftfGnwKALpt1AtXhptBTKtXGstjN4D9iAOxDZac8FaujboxDMpQgQBTQcpl4dL9NOstMjeyBFd5CBFl4ZmkRt8A0xovkO_PgL1s1SdVv9s1P_NnSC_JHTbACliBjGW1PEs7gq6wjCKCfaHjc9K9ssIATfFpNGWC4HT3V8BCY1XNvtDbcpfkOOS6DuwyXhO6vpS0TcOARZsM7nl_MISddG_A4fsl2acmZQpm5JeKuq86LR_juxByMUQMpQ2n-qu2-pJpZJeKuq86LpduKk0quevF.',
    'origin': 'https://web.shanbay.com',
    'priority': 'u=1, i',
    'referer': 'https://web.shanbay.com/',
    'sec-ch-ua': '"Chromium";v="128", "Not;A=Brand";v="24", "Microsoft Edge";v="128"',
    'sec-ch-ua-mobile': '?0',
    'sec-ch-ua-platform': '"Windows"',
    'sec-fetch-dest': 'empty',
    'sec-fetch-mode': 'cors',
    'sec-fetch-site': 'same-site',
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 Edg/128.0.0.0',
    #'x-csrftoken': 'd9858d879d14adc8f1179e2264c29e43',
}

params = {
    'ipp': '10',
    'page': '3',
}

response = requests.get(
    'https://apiv3.shanbay.com/wordsapp/user_material_books/buksun/learning/words/unlearned_items',
    params=params,
    cookies=cookies,
    headers=headers,
)
t=response.json()['data']
print(t)
with open('./扇贝单词.js', 'r', encoding='utf-8') as js_file:
    js_code = js_file.read()
js_compile = json.loads(execjs.compile(js_code).call('d',t))['objects']
print(json.dumps(js_compile, ensure_ascii=False, indent=4))